#include<stdio.h>
int main()
{
int price,depreciation,x=1,year,acc_depreciation,end_v alue;
char ans;
do{
printf("The price of the machine (RM):");
scanf("%d",&price);
printf("The rate of depreciation (RM):");
scanf("%d",&depreciation);
printf("Years of depreciation :");
scanf("%d",&year);
end_value=price-(year*depreciation);
acc_depreciation=price-end_value;
printf("YEAR DEPRECIATION END-YEAR-VALUE ACCUMULATED DEPRECIATION\n");
printf("---- ------------ -------------- ------------------------\n");
for(x=1;x<=year;x++)
{
printf("%d %d %d %d\n", x,depreciation,price-(x*depreciation),x*depreciation);
}
{
if(end_value<price/2)
printf("The final end-year-value (RM %d) is less than half of the actual price (RM %d).\n",end_value,price/2);
else if(end_value>price/2)
printf("The final end-year-value (RM %d) is greater than half of the actual price (RM %d).\n",end_value,price/2);
else
printf("The final end-year-value (RM %d) is equals to half of the actual price (RM %d).\n",end_value,price/2);
}
printf("Do you want to continue? Y-yes,N-no: ");
fflush(stdin);
scanf("%c\n",&ans);
}while(ans=='Y');
system("pause");
return 0;
}